<template>
    <div class="personalRec-container">
        <el-carousel :interval="4000" type="card" height="230px">
            <el-carousel-item v-for="item of banners.arr" :key="item">
                <img :src="item.pic" class="card-img">
            </el-carousel-item>
        </el-carousel>
        <div style="display: flex; justify-content: space-around">
            <round-btn v-for="item in roundBtn.arr" :key="item" :name="item"></round-btn>
        </div>

    </div>
</template>

<script>
import roundBtn from "./roundBtn.vue";

import {mainApi} from "../../../../api/mainApi.js";
import {onMounted, reactive} from "vue";
export default {
    name: "personalRec",
    components:{
        roundBtn
    },
    setup() {
        let banners = reactive({arr:[]})
        let roundBtn = reactive({arr:[]})

        async function getBlockMsg() {
            await mainApi.blockMsg((res)=>{
                banners.arr = res.data.data.blocks[0].extInfo.banners
            })
        }

        async function getRoundBtn() {
            await mainApi.roundBtn((res)=>{
                res.data.data.forEach((item,index)=>{
                    if (index === 0||index === 3|| index ===5 || index === 4 ||index === 1) {
                        roundBtn.arr.push(item.name)
                    }
                })
                console.log(roundBtn.arr)
            })
        }

        onMounted(()=>{
            getRoundBtn()
            getBlockMsg()
        })

        return {
            banners,
            roundBtn
        }
    }
}
</script>

<style scoped>
.personalRec-container {
    width: 100%;
    height: auto;
}


.el-carousel__item h3 {
    color: #475669;
    opacity: 0.75;
    line-height: 170px;
    margin: 0;
    text-align: center;
}

.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
    background-color: #d3dce6;
}

.card-img {
    width: 100%;
    height: 100%;
}
</style>